import axios from 'axios'
import { Indicator, Toast } from 'mint-ui'
const ajax = axios.create({
  baseURL: 'http://rap2api.taobao.org/app/mock/121431'
})

ajax.interceptors.request.use(config => {
  Indicator.open('加载中…')
  return config
})

ajax.interceptors.response.use(resp => {
  Indicator.close()
  if (resp.data.code === 200) {
    return resp.data.data
  } else {
    Toast({
      message: '请求出错',
      duration: 3000
    })
  }
})

export const getSwiper = () => {
  return ajax.get('/api/v1/swiper')
}
